
#ifndef _Weapon_H_
#define _Weapon_H_

#include "../WorldObject.h"
//#include "../Ship.h"
#include "../Utils/Timer.h"

class Ship;

class WeaponProjectile : public WorldObject {
  public:
    virtual ~WeaponProjectile(){};
   
    WorldObjectType getObjectType(void) const { 
        return WEAPON_PROJECTILE_WOBJECT; 
    }
 
  protected:

};


class WeaponGenerator {
  public:
    WeaponGenerator(int ammo_count, int lifetime, float rof, Ship *pship) :
        ammo_count(ammo_count),
        spawn_time(Timer::currentTicks()),
        lifetime(lifetime),
        rate_of_fire(rof),
        time_of_last_fire(0),
        parent_ship(pship) {

    }

    virtual ~WeaponGenerator(){};

    virtual bool shouldDiscard(void) = 0;

    // Returns NULL if weapon cannot fire at this point 
    // in time, otherwise returns a pointer to a newly 
    // generated weapon projectile.
    virtual bool fire(void) = 0;

  protected:

    // How many shots are left. -1 means infinite
    int ammo_count;

    // the ticks count at the time when the weapon was picked up
    const unsigned int spawn_time;
    const int lifetime; // in seconds how long this weapon lasts, if -1 infinite
    const float rate_of_fire; // seconds between firing.

    unsigned int time_of_last_fire;

    Ship *parent_ship;
};

#endif

